public class BBB extends Thread {
    private User user;
    private DDD ddd;

    public BBB(User user,DDD ddd){
        this.user=user;
        this.ddd=ddd;

    }

    @Override
    public void run() {
        synchronized (user){
            try {
                user.setName("bbb");
                ddd.setName("bbb");

                Thread.sleep(0);
                System.out.println("B进来了修改了对象user,现在的user叫"+user.getName());
                System.out.println("B进来了修改了对象ddd,现在的ddd叫"+ddd.getName());

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
